﻿using Microsoft.AspNetCore.Http;
using Models.Common;
using NetTaste;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using UtilsCache;
using UtilsORM;
using UtilsORM.MySqlData;

////using System.Web.Script.Serialization;

namespace GatewayServerService.Data
{
    public class DBIotDeviceTaskTimeIntervalLog
    {

        static string LogSave = UtilAppsettingCache.getSetting("base:logSave");
        // static object obj = new object();
        public void saveLogSync(iot_device_task_time_interval interval)
        {
            Task.Run(() =>
            {
                try
                {
                    if (LogSave == "false")
                    {
                        return;
                    }

                    EFYihongIotContext ef = new EFYihongIotContext();

                    iot_device_task_time_interval req = new iot_device_task_time_interval();
                    //先查一下有没重复提交

                    iot_device_task_time_interval_log model = new iot_device_task_time_interval_log();
                    //写入
                    model.l_guid = Guid.NewGuid().ToString();
                    model.l_ti_guid = interval.ti_guid;
                    model.l_add_time = DateTime.Now;
                    ef.iot_device_task_time_interval_log.Add(model);
                    ef.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            });
        }
    }
}